package com.java.dormitorymanager.mvc.view;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @program: DormitoryManager
 * @description: 添加学生界面
 * @author: ShuangChenYue
 * @create: 2021-05-17 09:14
 **/
@WebServlet(value = "/ViewAddStudent")
public class ViewAddStudentServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        System.out.println("点击添加学生按钮进入该方法");
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");
        PrintWriter out = resp.getWriter();

        out.println("<!DOCTYPE html>");
        out.println("<html lang=\"en\">");
        out.println("<head>");
        out.println("<meta charset=\"UTF-8\">");
        out.println("<title>添加学生</title>");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/DormitoryManager/css/css-student/addStudent.css\">");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/DormitoryManager/css/css-other/upIcon.css\">");
        out.println("</head>");
        out.println("<body>");
        out.println("<div id=\"divTitle\">");
        out.println("<h1 id=\"h01\"> Manage Students</h1>");
        out.println("</div>");
        out.println("<div id=\"registerBox\">");
        out.println("<h1>Add Student</h1>");
        out.println("<form id=\"registerForm\" action=\"/DormitoryManager/mvc/addStudent.do\" method=\"post\">");
        out.println("<table id=\"registerTable\">");
        out.println("<tr>");
        out.println("<td id=\"tdName\" colspan=\"2\"><i id=\"nameIcon\" class=\"iconfontAD\">&#xe669;</i><input id=\"inputName\" type=\"text\" name=\"name\" placeholder=\"name\"></td>");
        out.println("</tr>");
        out.println("<tr>");
        out.println("<td id=\"tdPassword\" colspan=\"2\"><i id=\"passwordIcon\" class=\"iconfontAD\">&#xe668;</i><input id=\"inputPassword\" type=\"password\" name=\"password\" placeholder=\"password\"></td>");
        out.println("</tr>");
        out.println("<tr>");
        out.println("<td id=\"tdStunum\"><i id=\"stunumIcon\" class=\"iconfontAD\">&#xe675;</i><input id=\"inputStunum\" type=\"text\" name=\"stunum\" placeholder=\"学生编号\"></td>");
        out.println("<td id=\"tdAge\"><i id=\"ageIcon\" class=\"iconfontAD\">&#xe62f;</i><input id=\"inputAge\" type=\"text\" name=\"age\" placeholder=\"学生年龄\"></td>");
        out.println("</tr>");
        out.println("<tr>");
        out.println("<td id=\"tdGender\"><i id=\"genderIcon\" class=\"iconfontAD\">&#xe63e;</i>");
        out.println("<select id=\"selectGender\" name=\"gender\">");
        out.println("<option value =\"#\">学生性别</option>");
        out.println("<option value =\"male\">male</option>");
        out.println("<option value =\"female\">female</option>");
        out.println("</select></td>");
        out.println("<td id=\"tdStatus\"><i id=\"statusIcon\" class=\"iconfontAD\">&#xe635;</i><input id=\"inputStatus\" type=\"text\" name=\"status\" placeholder=\"学生状态\"></td>");
        out.println("</tr>");
        out.println("<tr>");
        out.println("<td id=\"tdEmail\" colspan=\"2\"><i id=\"emailIcon\" class=\"iconfontAD\">&#xe631;</i><input id=\"inputEmail\" type=\"email\" name=\"email\" placeholder=\"邮箱地址\"></td>");
        out.println("</tr>");
        out.println("<tr>");
        out.println("<td id=\"tdSubmit\" colspan=\"2\"><input id=\"inputSubmit\" type=\"submit\" value=\"Add\" title=\"点击注册\"></td>");
        out.println("</tr>");
        out.println("</table>");
        out.println("</form>");
        out.println("</div>");
        out.println("</body>");
        out.println("</html>");
        out.flush();
        out.close();
    }
}
